{template 'common/header'}
<title>拼团活动</title>
<link href="../addons/ewei_shop/plugin/commission/template/mobile/default/static/datepicker/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../addons/ewei_shop/plugin/commission/template/mobile/default/static/datepicker/date.js" ></script>
<script type="text/javascript" src="../addons/ewei_shop/plugin/commission/template/mobile/default/static/datepicker/iscroll.js" ></script>
<script src="../addons/ewei_shop/static/js/dist/ajaxfileupload.js" type="text/javascript"></script>

<link href="{$_W['siteroot']}app/resource/css/bootstrap.min.css?v=20150403" rel="stylesheet">
<link rel="stylesheet" href="../addons/amouse_ecard/style/css/nameCard.css?v=201410256">
<script src="{$_W['siteroot']}app/resource/js/require.js"></script>
<script src="{$_W['siteroot']}app/resource/js/app/config.js"></script>
<script type="text/javascript">
            $(function(){
            //$('#beginTime').date();
            $('#starttime').date({theme:"datetime"});
                    $('#overtime').date({theme:"datetime"});
            });
</script>
<style type="text/css">
    body {margin:0px; background:#efefef; font-family:'微软雅黑'; -moz-appearance:none;}
    a {text-decoration:none;}
    .myshop_addnav {height:44px; width:94%; padding:0 3%; border-bottom:1px solid #f0f0f0; border-top:1px solid #f0f0f0; margin-top:14px; line-height:42px; color:#666; background:#fff;}
    .myshop_addnav {height:40px; width:94%; padding:0 3%; border-bottom:1px solid #f0f0f0; border-top:1px solid #f0f0f0; margin-top:14px; line-height:40px; color:#666; }
    .myshop_main {height:auto;width:100%; padding:0px 3%; border-bottom:1px solid #f0f0f0; border-top:1px solid #f0f0f0; margin-top:14px; background:#fff;}
    .myshop_main .line {height:44px; width:100%; border-bottom:1px solid #f0f0f0; line-height:44px;}

    .myshop_main .line .label { float:left;width:75px;font-size:14px;color:#555;line-height:34px;}
    .myshop_main .line .info { float:right; width:100%; margin-left:-75px;text-align: right;overflow:hidden;height:44px;}
    .myshop_main .line .info .inner { color:#666;margin-left:75px;}

    .myshop_main .line1 {height:80px; width:100%; border-bottom:1px solid #f0f0f0; line-height:80px;}
    .myshop_main .line1 .label { float:left;width:70px;color:#555;line-height:34px;}
    .myshop_main .line1 .info { float:right; width:100%; margin-left:-75px;;overflow:hidden;height:80px;}
    .myshop_main .line1 .info .inner { color:#666;margin-left:75px;padding-top:10px;}
    .myshop_main .line1 .info .inner .plus { float:left;width:60px;height:60px;border:1px solid #efefef; color:#efefef;; font-size:45px;line-height:55px;text-align:center;}
    .myshop_main .line1 .info .inner .plus1 { float:left;width:90%;height:60px;border:1px solid #efefef; color:#efefef;; font-size:45px;line-height:55px;text-align:center;}

    .myshop_main .line1 .info .inner .preview0 { position:absolute; width:60px;height:60px;z-index:2}
    .myshop_main .line1 .info .inner .preview1 { position:absolute; width:90%;height:60px;z-index:2}

    .myshop_main .line1 .info .inner .preview0 img,.myshop_main .line1 .info .inner .preview1 img { width:100%;height:100%;}

    .myshop_main .line input {float:left; height:40px; width:100%; padding:0px; margin:0px; border:0px; outline:none; font-size:14px; color:#666;padding-left:5px;}
    .myshop_main .line select  {float:left; border:none;height:44px;width:100%;color:#666;font-size:14px;}
    .myshop_sub1 {height:44px; width:94%; margin:14px 3% 0px; background:#ff4f4f; border-radius:4px; text-align:center; font-size:16px; line-height:44px; color:#fff;}
    .myshop_sub2 {height:44px; width:94%; margin:14px 3% 0px; background:#ddd; border-radius:4px; text-align:center; font-size:16px; line-height:44px; color:#666; border:1px solid #d4d4d4;}

    .myshop_main .line2 {width:100%;  line-height:25px; color:#666;overflow:hidden; font-size:13px;word-break: break-all;}

    textarea {height:60px;line-height:22px; width:100%;padding:5px;font-size:13px; background:#fff; padding-left:2%; border:1px solid #e9e9e9; margin:14px 0px 0; -webkit-appearance: none;} 
    .myshop_menu {height:44px; background:#fff;}
    .myshop_menu .nav {height:44px; width:50%; border-bottom:1px solid #f1f1f1;background:#fff; border-left:1px solid #f1f1f1; float:left; line-height:44px; font-size:14px; color:#666; text-align:center;}
    .myshop_menu .navon {height:42px; color:#ff771b; border-bottom:2px solid #ff771b;}

    .myshop_main .pic { border:1px solid #e9e9e9;width:100%;height:40px;border-radius:5px;color:#999;padding:3px;line-height:35px;font-size:13px;padding-left:10px;}
    .myshop_main .pic span {float:left;width:150px;}
    .myshop_main .pic .plus { float:right;width:30px;height:30px;border:1px solid #e9e9e9; color:#dedede;; font-size:18px;line-height:30px;text-align:center;}
    .myshop_main .pic .plus i { left:7px;top:7px;}
    .myshop_main .pic .images {float: right; width:auto;height:30px;}
    .myshop_main .pic .images .img { float:left; position:relative;width:30px;height:30px;border:1px solid #e9e9e9;margin-right:5px;}
    .myshop_main .pic .images .img img { position:absolute;top:0; width:100%;height:100%;}
    .myshop_main .pic .images .img .minus { position:absolute;color:red;width:8px;height:12px;top:-15px;right:-1px;}
    .info2 {padding:10px;border-bottom:1px solid #eee; border-top:1px solid #eee;}
    .info2 .con {height:auto; padding:10px 0px;}
    .info2 .con .line2 {height:auto; overflow:hidden; margin-bottom:5px;}
    .info2 .con .line2 .t1 {height:auto; width:55px; float:left; font-size:14px; color:#666; line-height:20px;}
    .info2 .con .line2 .t2 {padding-left:0px; background:#f90;}
    .info2 .con .line2 .t2 .t3 {height:auto; float:left; font-size:14px; color:#999;}
    input.inputDate{width:120px;}
    #dateshadow{height:0px;}
    #datePage{top:300px !important;}
    .biaoji {color:red;}
    .fillIn-inner .fillIn-inner-item .fillIn-avatar-thumbnail{background:none;border-radius:0px;-webkit-border-radius:0px;}
    .fillIn-inner .ico-upload{background:url(../addons/amouse_ecard/style/images/upload.jpg) no-repeat;background-size:50px;}
</style>
<div id='container'></div>
<div class="page_topbar">
    <a href="javascript:;" class="back" onclick="location.href = '{php echo $this->createPluginMobileUrl('commission/myshop/activity_list')}'"><i class="fa fa-angle-left"></i></a>
    <div class="title">拼团活动</div>
</div>
<div id="datePlugin"></div>
<div class="myshop_menu">
    <div class="nav navon" style="border-left:0px;width:49%;" onclick="location.href = '{php echo $this->createPluginMobileUrl('commission/index/fightgroups')}'">编辑拼团商品</div>
    <div class="nav"  onclick="location.href = '{php echo $this->createPluginMobileUrl('commission/index/fightgroups_list')}'">拼团商品列表</div>
</div>
<div class="myshop_main" data-ogid='0' >
    <div class="line"><div class="label">商品名称：</div><div class="info"><div class="inner"><input type="text" id="gname" value="{$thisgoods['gname']}" placeholder="请输入商品名称"/></div></div></div>
    <div class="line"><div class="label">商品库存：</div><div class="info"><div class="inner"><input type="text" id="gnum" value="{$thisgoods['gnum']}" placeholder="请输入商品库存"/></div></div></div>
    <div class="line"><div class="label">商品销量：</div><div class="info"><div class="inner"><input type="text" id="salenum" value="{$thisgoods['salenum']}" placeholder="请输入商品销量"/></div></div></div>
    <div class="line" style="display: none"><div class="label">女王价：</div><div class="info"><div class="inner"><input type="text" id="gprice" value="0.02" placeholder="请输入开团价格"/></div></div></div>
    <div class="line" style="display: none"><div class="label">王妃价：</div><div class="info"><div class="inner"><input type="text" id="gprice_two" value="0.01" placeholder="请输入加团价格"/></div></div></div>
    <div class="line"><div class="label">单买价格：</div><div class="info"><div class="inner"><input type="text" id="oprice" value="{$thisgoods['oprice']}" placeholder="请输入单买价格"/></div></div></div>
    <div class="line"><div class="label">市场价格：</div><div class="info"><div class="inner"><input type="text" id="mprice" value="{$thisgoods['mprice']}" placeholder="请输入市场价格"/></div></div></div>
    <div class="line" style="display:none;"><div class="label">起团人数：</div><div class="info"><div class="inner"><input type="text" id="groupnum" value="7" placeholder="请输入起团人数"/></div></div></div>
    <div class="line"><div class="label">组团限时：</div><div class="info"><div class="inner"><input type="text" id="endtime" value="{$thisgoods['endtime']}" placeholder="请输入组团限时(整数小时)"/></div></div></div>
    <div class="line"><div class="label">开始时间：</div><div class="info"><div class="inner"><input type="text"  id="starttime" value="{$thisgoods['starttime']}" /></div></div></div>
    <div class="line"><div class="label">结束时间：</div><div class="info"><div class="inner"><input  type="text" id="overtime" value="{$thisgoods['overtime']}"  /></div></div></div>
    <div class="line">
        <div class="label">商品状态：</div>
        <div class="info">
            <div class="inner">
                <select  id="isshow">
                    <option value="">请选择</option>
                    <option value="1" {if $thisgoods['isshow']==1}selected = "selected"{/if}>上架</option>
                    <option value="0" {if $thisgoods['isshow']==="0"}selected = "selected"{/if}>下架</option>
                </select>
            </div>
        </div>
    </div>
<!--     <section class="fillIn-column avatar-column">
        <ul class="fillIn-inner">
            <li class="fillIn-inner-item">
                <span class="fillIn-item-title" style="font-weight:700;font-size:14px;">首页图片</span>
                <div class="fillIn-avatar">
                    {php echo $amouse_ecard->tpl_form_field_icon_image2('gimg',$thisgoods['gimg']);}
                </div>
            </li>
        </ul>
    </section> -->
    <input type="hidden" name="gimg" value="images/5/2017/03/Uw64o880u88w8HToTw1hwnwTgttTKW.jpg" autocomplete="off" readonly="readonly">
<!--     {php echo $amouse_ecard->tpl_form_field_multi_image('img',$piclist);} -->
    <input type="hidden" name="img[]" value="images/5/2017/03/zzZ8uHSMSZhKRS19H7OrmlAR789Rz7.jpg">
    <input type="hidden" name="img[]" value="images/5/2017/03/KTi4LeOUoczkZ3JfLkL4ffEeuFTCUE.jpg">
    <div class="line2" style="display: none"><textarea id="gdesc" placeholder="请填写商品简介">{$thisgoods['gdesc']}</textarea></div>
    <div class="line2"><textarea id="gdetaile" placeholder="请填写商品详情">{$thisgoods['gdetaile']}</textarea></div>
</div>
<div class="myshop_sub1" id='myshop_submit'>确认</div>
<div class="myshop_sub1" id='record' onclick="location.href = 'http://wx.lanxuevip.com/app/index.php?i=5&c=entry&do=index&m=feng_fightgroups&opid={$openid}'">查看拼团</div>
<div class="info2">
</div>
<script language="javascript">
            $(".form-control").attr('placeholder',"商品幻灯片(最多五张)");
            require(['tpl', 'core'], function(tpl, core){
            function isEmpty(str)
            {
            if (str != null && str.length > 0)
            {
            return false;
            }
            return true;
            }
            $('#myshop_submit').click(function(){
            if ($(this).attr('saving') == '1'){
            return;
            }
            $(this).html('正在处理...').attr('saving', 1);
            if ($('#gname').isEmpty()){
            core.tip.show('请输入商品名称!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#gnum').isEmpty()){
            core.tip.show('请输入商品库存!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var gnum = $('#gnum').val();
            if (gnum < 0){
            core.tip.show('商品库存请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(gnum)){
            core.tip.show('商品库存，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#salenum').isEmpty()){
            core.tip.show('请输入商品销量!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var salenum = $('#salenum').val();
            if (salenum < 0){
            core.tip.show('商品销量请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(salenum)){
            core.tip.show('商品销量，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#gprice').isEmpty()){
            core.tip.show('请输入开团价格!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var gprice = $('#gprice').val();
            if (gprice < 0){
            core.tip.show('开团价格请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(gprice)){
            core.tip.show('开团价格，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#gprice_two').isEmpty()){
            core.tip.show('请输入加团价格!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var gprice_two = $('#gprice_two').val();
            if (gprice_two < 0){
            core.tip.show('加团价格请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(gprice_two)){
            core.tip.show('加团价格，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#oprice').isEmpty()){
            core.tip.show('请输入单买价格!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var oprice = $('#oprice').val();
            if (oprice < 0){
            core.tip.show('单买价格请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(oprice)){
            core.tip.show('单买价格，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#mprice').isEmpty()){
            core.tip.show('请输入市场价格!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var mprice = $('#mprice').val();
            if (mprice < 0){
            core.tip.show('市场价格请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(mprice)){
            core.tip.show('市场价格，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#groupnum').isEmpty()){
            core.tip.show('请输入起团人数!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var groupnum = $('#groupnum').val();
            if (groupnum < 0){
            core.tip.show('起团人数请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(groupnum)){
            core.tip.show('起团人数，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#endtime').isEmpty()){
            core.tip.show('请输入组团限时!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var endtime = $('#endtime').val();
            if (endtime < 0){
            core.tip.show('组团限时请输入大于0的数字!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if (isNaN(endtime)){
            core.tip.show('组团限时，请输入数字类型!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#starttime').isEmpty()){
            core.tip.show('请输入开始时间!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#overtime').isEmpty()){
            core.tip.show('请输入结束时间!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#isshow').isEmpty()) {
                core.tip.show('请选择商品状态!');
                $(this).html('提交').removeAttr('saving');
                return;
            }
            var gimg=document.getElementsByName("gimg");
            if(isEmpty(gimg[0].value)){
            core.tip.show('请上传首页图片!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var img=document.getElementsByName("img[]");
            if (isEmpty(img)) {
                core.tip.show('请上传幻灯片!');
                $(this).html('提交').removeAttr('saving');
                return;
            }
            var upload_img="";
            if(img.length>5){
                core.tip.show('上传幻灯片的数量不能超过五张!'); 
                return;
            }else{
                for(var i=0;i<img.length;i++){
                    upload_img+=img[i].value+";";
                }
            }
            if ($('#gdesc').isEmpty()){
            core.tip.show('请输入商品简介!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            if ($('#gdetaile').isEmpty()){
            core.tip.show('请输入商品详情!');
            $(this).html('确认').removeAttr('saving');
                    return;
            }
            var data = {
                    gname: $('#gname').val(),
                    gnum: $('#gnum').val(),
                    salenum: $('#salenum').val(),
                    gprice: $('#gprice').val(),
                    gprice_two: $('#gprice_two').val(),
                    oprice: $('#oprice').val(),
                    mprice: $('#mprice').val(),
                    groupnum: $('#groupnum').val(),
                    endtime: $('#endtime').val(),
                    starttime: $('#starttime').val(),
                    overtime: $('#overtime').val(),
                    isshow: $('#isshow').val(),
                    gimg: gimg[0].value,
                    img: upload_img,
                    gdesc: $('#gdesc').val(),
                    gdetaile: $('#gdetaile').val()
            }
            core.pjson('commission/index', {
                op:'fightgroups',
                data:data,
                id:"{$_GPC['id']}"
            }, function(postjson){
            if (postjson.status == 1){
            location.href='{php echo $this->createPluginMobileUrl('commission/index/fightgroups_list')}';
            }
            else{
            $(this).html('确认').removeAttr('saving');
                    core.tip.show(postjson.result);
            }
            }, true, true);
            });
            })
</script>
{template 'common/footer'}